<h1>View Livelihood Program "<?php echo $program ?>"</h1>

  <table>
    <tbody>
      <tr>
        <th>Name:&nbsp;</th>
        <td><?php echo $program->getName() ?></td>
      </tr>
      <tr>
        <th>Days:&nbsp;</th>
        <td><?php echo $program->getDays() ?></td>
      </tr>
      <tr>
        <th>Days to Grow:&nbsp;</th>
        <td><?php echo $program->getDaystogrow() ?></td>
      </tr>
      <tr>
        <th>Days to Process:&nbsp;</th>
        <td><?php echo $program->getDaystoprocess() ?></td>
      </tr>
      <tr>
        <th>Days to Market:&nbsp;</th>
        <td><?php echo $program->getDaystomarket() ?></td>
      </tr>
      <tr>
        <th>&nbsp;</th>
        <td><?php echo link_to("Edit Livelihood Program","program/edit?id=".$program->getId()) ?></td>
      </tr>
    </tbody>
  </table>


<br>
<b>Inputs:</b>
<table>
      <tr>
        <td>Input:</td>
        <td> | </td>
        <td>Quantity:</td>
        <td> | </td>
        <td>Price:</td>
      </tr>
    <?php foreach($program->getInputs() as $inputcontainer){$input=$inputcontainer->getRawValue(); ?>
    <tr>
      <td><?php echo $input->getName() ?></td>
      <td> | </td>
      <td><?php echo $input->getQty() ?></td>
      <td> | </td>
      <td><?php echo $input->getPrice() ?></td>
      <td> | </td>
      <td><?php echo link_to("Edit","input/edit?id=".$input["id"]); ?></td>
      <td> | </td>
      <td><?php echo link_to("Delete","input/delete?id=".$input['id'], array('method' => 'delete', 'confirm' => 'Delete '.$input['name'].': Are you sure?'));?></td>
    </tr>

    <?php }?>
  </tbody>
</table>

<br>
<!--new input-->
  <?php $input=new Input();$inputform=new InputForm($input); ?>
  <?php echo form_tag_for($inputform, '@input') ?>
    <?php echo $inputform->renderHiddenFields() ?>
    <input type="hidden" name="input[program_id]" id="input_program_id" value="<?php echo $program->getId()?>" />

    <?php if ($inputform->hasGlobalErrors()): ?>
      <?php echo $inputform->renderGlobalErrors() ?>
    <?php endif; ?>
  <table>
      <tr>
        <td>New Input:</td>
        <td>Quantity:</td>
        <td>Price:</td>
      </tr>
      <tr>
        <td><?php echo $inputform['name']->renderError() ?></td>
        <td><?php echo $inputform['qty']->renderError() ?></td>
        <td><?php echo $inputform['price']->renderError() ?></td>
      </tr>
      <tr>
        <td><?php echo $inputform['name'] ?></td>
        <td><?php echo $inputform['qty'] ?></td>
        <td><?php echo $inputform['price'] ?></td>
        <td><input type="submit" value="Save" /></td>
      </tr>
  </table>
</form>

<br>
<b>Batches:</b>
<table>
      <tr>
        <td>New Batch:</td>
      <td> | </td>
        <td>Start Date:</td>
      <td> | </td>
        <td>Grown Date:</td>
      <td> | </td>
        <td>Processed Date:</td>
      <td> | </td>
        <td>Marketed Date:</td>
      <td> | </td>
        <td>End Date:</td>
      </tr>
    <?php foreach($program->getBatchesDescOrder() as $batchcontainer){$batch=$batchcontainer->getRawValue(); ?>
    <tr>
      <td><?php echo $batch->getName() ?></td>
      <td> | </td>
      <td><?php echo MyDateTime::frommysql($batch->getStartdate())->toprettydate() ?></td>
      <td> | </td>
      <td><?php echo MyDateTime::frommysql($batch->getGrowndate())->toprettydate() ?></td>
      <td> | </td>
      <td><?php echo MyDateTime::frommysql($batch->getProcesseddate())->toprettydate() ?></td>
      <td> | </td>
      <td><?php echo MyDateTime::frommysql($batch->getMarketeddate())->toprettydate() ?></td>
      <td> | </td>
      <td><?php echo MyDateTime::frommysql($batch->getEnddate())->toprettydate() ?></td>
      <td> | </td>
      <td><?php echo link_to("Show","batch/show?id=".$batch["id"]); ?></td>
      <td> | </td>
      <td><?php echo link_to("Edit","batch/edit?id=".$batch["id"]); ?></td>
      <td> | </td>
      <td><?php echo link_to("Delete","batch/delete?id=".$batch['id'], array('method' => 'delete', 'confirm' => 'Delete '.$batch['name'].': Are you sure?'));?></td>
    </tr>

    <?php }?>
  </tbody>
</table>

<br>
<!--new batch-->
  <?php $batch=new Batch();$batchform=new BatchForm($batch); ?>
  <?php echo form_tag_for($batchform, '@batch') ?>
    <?php echo $batchform->renderHiddenFields() ?>
    <input type="hidden" name="batch[program_id]" id="batch_program_id" value="<?php echo $program->getId()?>" />

    <?php if ($batchform->hasGlobalErrors()): ?>
      <?php echo $batchform->renderGlobalErrors() ?>
    <?php endif; ?>
  <table>
      <tr>
        <td>New Batch:</td>
        <td>Start Date:</td>
        <td>Grown Date:</td>
        <td>Processed Date:</td>
        <td>Marketed Date:</td>
        <td>End Date:</td>
      </tr>
      <tr>
        <td><?php echo $batchform['name']->renderError() ?></td>
        <td><?php echo $batchform['startdate']->renderError() ?></td>
        <td><?php echo $batchform['growndate']->renderError() ?></td>
        <td><?php echo $batchform['processeddate']->renderError() ?></td>
        <td><?php echo $batchform['marketeddate']->renderError() ?></td>
        <td><?php echo $batchform['enddate']->renderError() ?></td>
      </tr>
      <tr>
        <td><?php echo $batchform['name'] ?></td>
        <td><?php echo $batchform['startdate'] ?></td>
        <td><?php echo $batchform['growndate'] ?></td>
        <td><?php echo $batchform['processeddate'] ?></td>
        <td><?php echo $batchform['marketeddate'] ?></td>
        <td><?php echo $batchform['enddate'] ?></td>
        <td><input type="submit" value="Save" /></td>
      </tr>
  </table>
</form>


